<?php
namespace app\admin\model;

use think\Model;

/**
 * 模型
 * @package app\admin\model
 */
class BusPlatGroupConfig extends Model
{
    protected $observerClass = 'app\admin\event\DeleteCache';

    public static function add($data)
    {
        return self::create($data);
    }

    public static function addAll($data, $pla, $ccpid)
    {
        // plat_id,plat_id_send,code,plat_type,range_size,province,route_flag,onoff
        foreach ($data as $k => $v) {
            $installData['plat_id_send'] = $v['plat_id_send'];
            $installData['plat_type']    = $v['plat_type'];
            $installData['range_size']   = $v['range_size'];
            $installData['code']         = $v['code'];
            $installData['province']     = $v['province'];

            $installData['route_flag']    = $v['route_flag'];
            $installData['onoff']         = $v['onoff'];
            $installData['correspond_id'] = $ccpid;
            $installData['plat_id']       = $pla;
            $installData['plat_index']    = getMaxPlatIndex($pla) + 1;

            self::create($installData);
        }
    }
}
